/**
 * 
 */
package com.wqr.it.ecwdr.vo;

import java.io.Serializable;

/**
 * 分页数据
 * @author adinos
 *
 */
public class PageVO implements Serializable {
	private static final long serialVersionUID = -646964691784823183L;
	private static final int maxPageSize = 50000;
	private static final int maxTotalRows = 7500000;
	private int curPage = 1;
	private int pageSize = 15;
	private int totalRows = 0;
	private int startIndex = 0;
	private int endIndex = 15;
	/**
	 * 获取当前页号
	 * @return 当前页
	 */
	public int getCurPage() {
		return curPage;
	}
	/**
	 * 设置当前页号
	 * @param curPage 当前页号
	 */
	public void setCurPage(int curPage) {
		if (curPage <=0) {
			this.curPage = 0;
		} else {
			this.curPage = curPage;
		}
		this.startIndex = (this.curPage - 1) * this.pageSize;
		this.endIndex = this.curPage * this.pageSize;
	}
	/**
	 * 获取总页数
	 * @return 总页数
	 */
	public int getTotalPage() {
		if (this.pageSize < 1)  {
			this.pageSize = 15;
		}
		return (this.totalRows - 1) / this.pageSize + 1;
	}

	/**
	 * 获取数据总条数 
	 * @return 数据总条数 
	 */
	public int getTotalRows() {
		return totalRows;
	}
	/**
	 * 设置数据总条数
	 * @param totalRows 数据总条数 
	 */
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}

	/**
	 * 获取每页数据条数，默认为15，最大为1000
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}
	/**
	 * 设置每页数据条数，默认为15，最大为1000
	 * @param pageSize 每页数据条数
	 */
	public void setPageSize(int pageSize) {
		if (pageSize < 1)  {
			this.pageSize = 15;
		} else if (pageSize > maxPageSize) {
			this.pageSize = maxPageSize;
		} else {
			this.pageSize = pageSize;
		}
		this.startIndex = (this.curPage - 1) * this.pageSize;
		this.endIndex = this.curPage * this.pageSize;
	}

	/**
	 * @return the startIndex
	 */
	public int getStartIndex() {
		return startIndex;
	}
	/**
	 * @param startIndex the startIndex to set
	 */
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	/**
	 * @return the endIndex
	 */
	public int getEndIndex() {
		return endIndex;
	}
	/**
	 * @param endIndex the endIndex to set
	 */
	public void setEndIndex(int endIndex) {
		this.endIndex = endIndex;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "PageVO [getCurPage()=" + getCurPage() + ", getTotalPage()=" + getTotalPage() + ", getTotalRows()="
				+ getTotalRows() +  ", getPageSize()=" + getPageSize()
				+ ", getStartIndex()=" + getStartIndex() + ", getEndIndex()=" + getEndIndex() + "]";
	}
	public static int getMaxTotalRows() {
		return maxTotalRows ;
	}
	public static int getMaxPageSize() {
		return maxPageSize ;
	}
	
	
}
